package com.swgk.core.dialog;

import android.content.Context;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Description:
 * Author zhengkewen
 * Time 2017/12/13
 */
public class DialogViewHolder extends RecyclerView.ViewHolder {

    private ViewDataBinding mBinding;
    private View dialog;

    public DialogViewHolder(View v) {
        super(v);
        this.dialog = v;
        mBinding = DataBindingUtil.bind(v);
    }

    public static DialogViewHolder get(Context context, ViewGroup viewGroup, int layoutId) {
        View itemView = LayoutInflater.from(context).inflate(layoutId, viewGroup, false);
        return new DialogViewHolder(itemView);
    }

    public View getDialog() {
        return dialog;
    }

    public DialogViewHolder setBinding(int variableId, Object object) {
        mBinding.setVariable(variableId, object);
        mBinding.executePendingBindings();
        return this;
    }

    public ViewDataBinding getmBinding() {
        return mBinding;
    }
}
